package com.area.cth.controller;

import com.area.cth.pojo.Feedback;
import com.area.cth.common.PageBean;
import com.area.cth.common.Result;
import com.area.cth.service.FeedbackService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Tag(name = "意见反馈相关接口")
@RestController
@RequestMapping("/feedback")
@CrossOrigin
public class FeedbackController {
    @Autowired
    private FeedbackService fs;

    @Operation(summary = "提交反馈")
    @PostMapping
    public Result submitFeedback(@RequestBody Feedback feedback) {
        fs.submitFeedback(feedback);
        return new Result(0,"提交成功",null);
    }

    @Operation(summary = "删除反馈")
    @DeleteMapping
    public Result deleteFeedback(Integer id) {
        fs.deleteFeedback(id);
        return Result.success();
    }

    @Operation(summary = "分页查询")
    @GetMapping("/list")
    public Result<PageBean<Feedback>> feedbackList(Integer pageNo, Integer pageSize) {
        PageBean<Feedback> ds = fs.feedbackList(pageNo, pageSize);
        return Result.success(ds);
    }

    @Operation(summary = "根据id查询意见反馈")
    @GetMapping
    public Result<Feedback> getFeedbackDetail(Integer id) {
        Feedback fb = fs.getFeedbackDetail(id);
        return Result.success(fb);
    }
}
